package com.javatest.springboot3minio.config;

import com.javatest.springboot3minio.utils.MinioBucketUtil;
import com.javatest.springboot3minio.utils.MinioFileUtil;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.stereotype.Component;

/**
 * Created with IntelliJ IDEA. Description:
 *
 * @author liuzi
 * @since 2024/1/10 10:48
 */
@Component
public class UtilsAutowireConfig implements SmartInitializingSingleton {
  private AutowireCapableBeanFactory autowireCapableBeanFactory;

  @Autowired
  public void setAutowireCapableBeanFactory(AutowireCapableBeanFactory autowireCapableBeanFactory) {
    this.autowireCapableBeanFactory = autowireCapableBeanFactory;
  }

  @Override
  public void afterSingletonsInstantiated() {
    autowireCapableBeanFactory.autowireBean(MinioBucketUtil.getBucketUtilSingleton());
    autowireCapableBeanFactory.autowireBean(MinioFileUtil.getFileUtilSingleton());
  }
}
